﻿using System;
using System.Collections.Generic;
using System.Text;
using FunctionalCLR;
using FunctionalCLR.Core;

namespace FunctionalCLR.Core.Function.String {
    public class IndexOfNode : FuncNode {

        public IndexOfNode()
            : base() {
            base.Value = "indexOf";
        }

        public override FuncNode GetReversedFunction(int index) {
            throw new NotImplementedException();
        }

        public override object Evaluate() {
            int length = Children.Count;

            string expr = Children[length - 1].Evaluate().ToString();
            string idx = Children[length - 2].Evaluate().ToString();

            return expr.IndexOf(idx);
        }
    }
}
